<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<base th:href="@{/}"/>
<link rel="stylesheet" th:href="@{/css/bootstrap.min.css}"/>
<link rel="stylesheet" th:href="@{/css/Managerstyle.css}"/>
<script th:src="@{/js/jquery-3.4.1.min.js}"></script>
<script th:src="@{/js/bootstrap.min.js}"></script>
<title>Insert title here</title>
</head>
<body>
	<div class="contain">
		<div class="query">
			<a href="mc/toInsertLessionPlan">返回</a>
			<h3>添加开课计划</h3>
			<span>该专业教学计划已设课程：</span>
			<table class="table">
				<tr>
					<td>所属学院</td>
					<td>专业</td>
					<td>学期</td>
					<td>课程名称</td>
				</tr>
				<tr th:id="|tr${lessionPlan.lpid}|">
					<td th:text="${lessionPlan.major.acadamy.acdmname}"></td>
					<td th:text="${lessionPlan.major.term.tyear}+${lessionPlan.major.mjname}"></td>
					<td th:text="${lessionPlan.term.termName}"></td>
					<td th:text="${lessionPlan.course.cname}"></td>
				</tr>
			</table>
			<span>选择老师：</span>
			<select id="selectAcadamy1" style="width: 200px;">
				<option value="">请选择学院</option>
				<option th:each="acadamy:${acadamyList}" th:value="${acadamy.acdmid}" th:text="${acadamy.acdmname}"></option>
			</select>
			<select id="selectTeacher" style="width: 150px" >
				<option value="">请选择老师</option>
			</select>
			<br />
			<br />
			<span>请选择班级：</span>
			<select name="" id="selectBatch" style="width: 150px;">
				<option value="">请选择班级</option>
				<option th:each="batch:${batchList}" th:value="${batch.bid}" th:text="${batch.bname}"></option>
			</select>
			<br />
			<br />
			<span>请选择上课教室类型：</span>
			<select name="" id="selectClasstype">
				<option value="1">普通教室</option>
				<option value="2">多媒体教室</option>
			</select>
			<input type="text" id="lpid" th:value="${lessionPlan.lpid}" style="display: none" />
			<button type="button" id="addOneButton" class="btn btn-info">添加</button>
			<span id="msg"></span>
		</div>
	</div>
	<script>
		$(document).ready(function(){
			
			$("#selectAcadamy1").change(function(){
				var str2 = "<option>请选择老师</option>" ; 
				$.ajax({
					url: "mc/getTeacherByAcdmid",
					type: "GET",
					data: {acdmid: $("#selectAcadamy1").val()},
					success: function(data){
						$("#selectTeacher").empty();
						$("#selectTeacher").append(str2);
						$.each(data,function(index,value){
							var str1 = "<option value='" + value.tid +"'>" + value.tname + "</option>";
							$("#selectTeacher").append(str1);
						});					
					},
					error: function(req,status,error){
						$("#selectTeacher").empty();
						$("#selectTeacher").append(str2);
					}
				});
				
			});
			
		 	
		 	$("#addOneButton").click(function(){
		 		$.ajax({
		 			url: 'mc/addOneCoursePlan',
		 			type: 'POST',
		 			data: {tid: $("#selectTeacher").val(), bid: $("#selectBatch").val(), lpid: $("#lpid").val(), classrmtype: $("#selectClasstype").val()},
		 			success: function(data){
		 				$("#msg").html(data);
		 			},
		 			error: function(req,status,error){
						alert("请填写完整信息！");
					}
		 		});
		 		
		 	});
			
		});
	</script>
	
</body>
</html>